/**
 * Company : SIANGKLOM.
 * Created By : Chatree Siangklom
 * Created On : Aug 30, 2013  2:38:21 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.interfaces.servlet
 * File Name : UserLogOnState.java
 * TODO
 */
package com.tis.interfaces.servlet;

import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import promis.utility.CommonService;

import com.tis.database.entitys.security.AdUserLogin;
import com.tis.interfaces.apps.SESSION_MANAGE;

/**
 * @author Chatree Siangklom of Administrator
 * Date =Aug 30, 2013 : 2:38:21 PM 
 * CreateBy=Chatree Siangklom
 * TODO
 */
public class UserLogOnState extends TagSupport {
	private static final long serialVersionUID = 1L;
	
	private static final Logger log = LoggerFactory.getLogger(UserLogOnState.class);
	
	private String value = "";
	public void setValue(String value) {
		this.value = value;
	}
	
	/** (Javadoc)
	 * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
	 * Date =Aug 30, 2013 : 2:39:09 PM 
	 * CreateBy=Chatree Siangklom 
	 * TODO
	 */
	@Override
	public int doStartTag() throws JspException {
		
		JspWriter out = pageContext.getOut();
		try{
						
			HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();			
			HttpSession session = request.getSession();		 	
			Object objSession = session.getAttribute(SESSION_MANAGE.SECURITY_PAGE.AdUserLogin);
			String chk = "FALSE";
					
				if(!CommonService.IsNull(objSession)){
					AdUserLogin adUserLoin = (AdUserLogin)objSession;
					if(!CommonService.IsNull(adUserLoin.getUserLogin())) 
						chk = "TRUE";
				}
			out.print(chk);
			
		}catch(IOException ex){
			log.error(ex.getMessage());
			throw new JspException("Error in UserLogOnState tag" + ex.getMessage());
		}
		return SKIP_BODY;
	}
	
	@Override
	public int doEndTag() throws JspException {
        return SKIP_PAGE;
    }
}
